package com.myblog.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.Query;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.myblog.mapper.Wechatmapper;
import com.myblog.pojo.Wechat;
import com.myblog.service.Wechatservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class Wechatserviceimpl implements Wechatservice {
    @Autowired
    private Wechatmapper wechatmapper;

    @Override
    public void insertwechat(Wechat wechat) {
        wechatmapper.insert(wechat);
    }

    @Override
    public int findcount(Object openId) {
        QueryWrapper<Wechat> wrapper=new QueryWrapper<>();
        wrapper.eq("openId",openId);
        return wechatmapper.selectCount(wrapper);
    }

    @Override
    public void update(Wechat wechat) {
        QueryWrapper<Wechat> wrapper=new QueryWrapper<>();
        wrapper.eq("openId",wechat.getOpenId());
        wechatmapper.update(wechat,wrapper);
    }

    @Override
    public int selectaccount(Object openId) {
        QueryWrapper<Wechat> wrapper=new QueryWrapper<>();
        wrapper.eq("openId",openId);
        Wechat wechat=wechatmapper.selectOne(wrapper);
        return wechat.getAccount();
    }

    @Override
    public List<Wechat> findwxphoto() {
        return wechatmapper.findwxphoto();
    }
}
